1. Fix bug with field delimiter getting overwritten by record delimiter.
authoralexmot <alexmot@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 29 Jul 2003 15:49:07 +0000 (15:49 +0000)
committeralexmot <alexmot@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 29 Jul 2003 15:49:07 +0000 (15:49 +0000)
2. Add field and record delimiters to bad characters by default.

gpsbabel/xcsv.c

index 248ef58d83084ed0075ab3b3e8c4fd365f6371c4..259992577a26960285215bf25128105155c1e64e 100644 (file)
@@ -205,6 +205,22 @@ xcsv_parse_style_line(const char *sbuff)
            }
            else
                xcsv_file.field_delimiter = sp;
+
+               p = csv_stringtrim(xcsv_file.field_delimiter, " ", 0);
+
+               /* field delimiters are always bad characters */
+               if (xcsv_file.badchars) {
+                       xcsv_file.badchars = xrealloc(xcsv_file.badchars,
+                               strlen(xcsv_file.badchars) +
+                               strlen(p) + 1);
+               } else {
+                       xcsv_file.badchars = xcalloc(strlen(p) + 1, 1);
+               }
+
+               strcat(xcsv_file.badchars, p);
+               
+               xfree(p);
+
        } else
 
        if (ISSTOKEN(sbuff, "RECORD_DELIMITER")) {
@@ -215,7 +231,23 @@ xcsv_parse_style_line(const char *sbuff)
                xfree(sp);
            }
            else
-               xcsv_file.field_delimiter = sp;
+               xcsv_file.record_delimiter = sp;
+               
+               p = csv_stringtrim(xcsv_file.record_delimiter, " ", 0);
+
+               /* record delimiters are always bad characters */
+               if (xcsv_file.badchars) {
+                       xcsv_file.badchars = xrealloc(xcsv_file.badchars,
+                               strlen(xcsv_file.badchars) +
+                               strlen(p) + 1);
+               } else {
+                       xcsv_file.badchars = xcalloc(strlen(p) + 1, 1);
+               }
+
+               strcat(xcsv_file.badchars, p);
+               
+               xfree(p);
+               
        } else
 
        if (ISSTOKEN(sbuff, "DESCRIPTION")) {
@@ -239,12 +271,26 @@ xcsv_parse_style_line(const char *sbuff)
        if (ISSTOKEN(sbuff, "BADCHARS")) {
            sp = csv_stringtrim(&sbuff[9], "\"", 1);
            cp = get_char_from_constant_table(sp);
+
            if (cp) {
-               xcsv_file.badchars = xstrdup(cp);
+               p = xstrdup(cp);
                xfree(sp);
            }
            else
-               xcsv_file.badchars = sp;
+               p = sp;
+               
+               if (xcsv_file.badchars) {
+                       xcsv_file.badchars = xrealloc(xcsv_file.badchars,
+                               strlen(xcsv_file.badchars) +
+                               strlen(p) + 1);
+               } else {
+                       xcsv_file.badchars = xcalloc(strlen(p) + 1, 1);
+               }
+
+               strcat(xcsv_file.badchars, p);
+               
+               xfree(p);
+               
        } else
 
        if (ISSTOKEN(sbuff, "PROLOGUE")) {